﻿
@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<form id="form1">
    <div style="margin-right:35px;margin-top:10px;">
        <table class="form">
            <tr>
                <th class="formTitle">名称</th>
                <td class="formValue">
                    <input id="FullName" name="FullName" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" placeholder="请输入名称" />
                </td>
                <th class="formTitle">编号</th>
                <td class="formValue">
                    <input id="EnCode" name="EnCode" type="text" class="form-control" isvalid="yes" checkexpession="NotNull" placeholder="请输入编号" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">上级</th>
                <td class="formValue">
                    <select id="ParentId" name="ParentId" class="form-control">
                        <option value="0">父节点</option>
                    </select>
                </td>
                <th class="formTitle">位置</th>
                <td class="formValue">
                    <select id="Location" name="Location" class="form-control" isvalid="yes" checkexpession="NotNull">
                        <option value="">==请选择==</option>
                        <option value="1">初始</option>
                        <option value="2">选中</option>
                    </select>
                </td>
            </tr>
            <tr>
                <th class="formTitle">事件</th>
                <td class="formValue">
                    <input id="JsEvent" name="JsEvent" type="text" class="form-control" />
                </td>
                <th class="formTitle">连接</th>
                <td class="formValue">
                    <input id="UrlAddress" name="UrlAddress" type="text" class="form-control" />
                </td>
            </tr>
            <tr>
                <th class="formTitle">图标</th>
                <td class="formValue">
                    <div class="input-group">
                        <input id="Icon" name="Icon" type="text" class="form-control">
                        <span class="input-group-btn">
                            <a class="btn  btn-primary"><i class="fa fa-ellipsis-h"></i></a>
                        </span>
                    </div>
                </td>
                <th class="formTitle">排序</th>
                <td class="formValue">
                    <input id="SortCode" name="SortCode" type="text" class="form-control" isvalid="yes" checkexpession="Num" />
                </td>
            </tr>
            <tr>
                <th class="formTitle" style="height: 35px;">选项</th>
                <td class="formValue" colspan="3" style="padding-top: 1px;">
                    <div class="checkbox user-select">
                        <label><input id="Split" name="Split" type="checkbox">分开线</label>
                        <label><input id="IsPublic" name="IsPublic" type="checkbox">公共</label>
                        <label><input id="EnabledMark" name="EnabledMark" type="checkbox" checked="checked">有效</label>
                        <label><input id="AllowEdit" name="AllowEdit" type="checkbox">允许编辑</label>
                        <label><input id="AllowDelete" name="AllowDelete" type="checkbox">允许删除</label>
                    </div>
                </td>
            </tr>
            <tr>
                <th class="formTitle" valign="top" style="padding-top: 5px;">
                    描述
                </th>
                <td class="formValue" colspan="3">
                    <textarea id="Description" name="Description" class="form-control" style="height: 100px;"></textarea>
                </td>
            </tr>
        </table>
    </div>
</form>
<script>
    var keyValue = $.fn.request("keyValue");
    var moduleId = $.fn.request("moduleId");
    $(function () {
        initControl();
        if (!!keyValue) {
            $.fn.setForm({
                url: "/SystemManage/ModuleButton/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                }
            })
        }

    })
    function initControl() {
        $("#Location").select2({ minimumResultsForSearch: -1 })
        $("#ParentId").bindSelect({
            url: "/SystemManage/ModuleButton/GetTreeSelectJson",
            param: { moduleId: moduleId },
        });
    }
    function submitForm() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = $("#form1").GetWebControls();
        postData["ModuleId"] = moduleId;
        $.fn.submitForm({
            url: "/SystemManage/ModuleButton/SubmitForm?keyValue=" + keyValue,
            param: postData,
            success: function () {
                //alert(parent.layer.getFrameIndex(window.name));
                //parent.location.reload();
                //var iframeWin = window[layero.find('iframe')[0]['name']];
                //iframeWin.reloadPage();
                // window.parent.shuaxin();
                //$.currentIframe().$("#gridTable").resetSelection().trigger("reloadGrid");
            }
        })
    }
</script>
